package com.ruoyi.api.service.impl;

import com.ruoyi.api.service.SelectSaleService;
import com.ruoyi.product.domain.ProductModel;
import com.ruoyi.sale.domain.SaleorderOrder;
import com.ruoyi.sale.mapper.SaleorderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

@Service
public class SelectSaleServiceImpl implements SelectSaleService {
    @Autowired
    private SaleorderMapper saleorderMapper;

    /**
     * 查询销售订单情况
     *
     * @param saleorderOrder 查询条件
     * @return 结果
     */
    @Override
    public List<SaleorderOrder> selectSaleorderOrderList(SaleorderOrder saleorderOrder) {
        return saleorderMapper.selectSaleorderOrderList(saleorderOrder);
    }

    /**
     * 查看销售订单
     *
     * @param hashMap 查询条件
     * @return 结果
     */
    @Override
    public SaleorderOrder selectSaleorderById(HashMap<String, Object> hashMap) {
        return saleorderMapper.selectSaleorderById(hashMap);
    }

    /**
     * 查询产品规格信息
     *
     * @param map 查询条件
     * @return 结果
     */
    @Override
    public List<ProductModel> selectTableList(HashMap map) {
        return saleorderMapper.selectTableList(map);
    }

    /**
     * 插入销售订单 主表信息
     *
     * @param saleorderOrder 销售订单信息
     * @return 结果
     */
    @Transactional
    @Override
    public int insertSaleorder(SaleorderOrder saleorderOrder) {
        return saleorderMapper.insertSaleorder(saleorderOrder);
    }

    /**
     * 插入销售订单 从表信息
     *
     * @param saleorderOrder 销售订单信息
     * @return 结果
     */
    @Transactional
    @Override
    public int insertSaleorderModel(SaleorderOrder saleorderOrder) {
        return saleorderMapper.insertSaleorderModel(saleorderOrder);
    }

    /**
     * 查询销售订单PDF
     *
     * @param saleorderId 查询条件
     * @return 结果
     */
    @Override
    public String selectSaleorderPdf(Long saleorderId) {
        return saleorderMapper.selectSaleorderPdf(saleorderId);
    }

    /**
     * 查询是否生成销售订单的
     *
     * @param hashMap 查询条件
     */
    @Override
    public SaleorderOrder selectSaleorderByMap(HashMap<String, Object> hashMap) {
        return saleorderMapper.selectSaleorderByMap(hashMap);
    }
}
